package com.etc.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LoginServlet extends HttpServlet{
	// get请求触发
	/**
	 * 
	 * @param req  请求
	 * @param resp  响应
	 * @throws ServletException
	 * @throws IOException
	 */
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		System.out.println("doGet");
		this.doPost(req, resp);
	}
	// post请求触发
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		System.out.println("doPost");
		String str = "hello world";
		resp.setContentType("text/html");
		PrintWriter pw = resp.getWriter();
		pw.write("<html><head></head><body>"
				+ "<h1>"
				+ str
				+ "</h1>"
				+ "</body></html>");
	}

	
}
